<template>
	<list ref="list" style="width:750rpx; flex: 1;" :show-scrollbar="false" :bounce="false" :loadmoreoffset="100" @loadmore="onLoadmoreAction" fixFreezing="true">
		<cell v-for="(item, index) in list" :key="index">
			<view style="border: 1px; height: 80rpx; margin: 40rpx;">{{item}}</view>
		</cell>
	</list>
</template>

<script>
	export default {
		props: {
			parentId: {
				type: String,
				default: ''
			},
			current: {
				type: Number,
				default: 0
			},
			index: {
				type: Number,
				default: 0
			},
		},
		data(){
			return {
				list: []
			}
		},
		created() {
			if (this.index === this.current) {
				setTimeout(() => {
					this.onLoadmoreAction()
				}, 30)
			}
		},
		watch: {
			current(newV) {
				if (newV === this.index) {
					this.onLoadmoreAction()
				}
			}
		},
		methods: {
			
			onLoadmoreAction(){
				setTimeout(() => {
					let datas = [];
					for(let i = this.list.length; i < this.list.length+10; i++){
						datas.push(i);
					}
					this.list = this.list.concat(datas);
				}, 500)
			},
			
			setScrollRef(allHeight) {
				if (this.$refs['list'].setSpecialEffects) {
					this.$refs["list"].setSpecialEffects({id: this.parentId, headerHeight: allHeight});
				}
			}
		}
	}
</script>

<style>
</style>
